import { ElMessageBox, ElMessage } from 'element-plus';
import { ref } from 'vue';

export function global() {
    const confirm = (params) => {
        ElMessageBox.confirm(params.content, params.tip || "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: params.tpye || "warning",
                center: true,
            })
            .then(() => {
                ElMessage({
                    type: "success",
                    message: "删除成功!",
                });
                params.fn && params.fn(params.value)
            })
            .catch(() => {
                ElMessage({
                    type: "info",
                    message: "已取消删除",
                });
            });
    }

    return { confirm }
}